//
//  SCEmoticonCell.swift
//  表情键盘
//
//  Created by newuser on 15/12/28.
//  Copyright © 2015年 newuser. All rights reserved.
//

import UIKit

class SCEmoticonCell: UICollectionViewCell {
    
    
    var emoticon: CZEmociton? {
        didSet {
            if let pngPath = emoticon?.pngPath {
                emoticonButton.setImage(UIImage(contentsOfFile: pngPath), forState: UIControlState.Normal)
            }else {
              emoticonButton.setImage(nil, forState: UIControlState.Normal)
            }
            emoticonButton.setTitle(emoticon?.emoji, forState: UIControlState.Normal)
            //显示删除按钮
            if emoticon!.removeEmoticon {
            emoticonButton.setImage(UIImage(named: "compose_emotion_delete_highlighted"), forState: UIControlState.Normal)
            }
        
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        prepareUI()
    }
    
    //准备UI
    func prepareUI() {
    
        contentView.addSubview(emoticonButton)
        
        //设置约束
        emoticonButton.frame = CGRectInset(bounds, 3, 3)
        
    }

    //MARK: - 显示图片
    private lazy var emoticonButton: UIButton = {
         let button = UIButton()
        
         //设置字体大小
          button.titleLabel?.font = UIFont.systemFontOfSize(32)
           //取消用户交互
          button.userInteractionEnabled = false
        
        return button
        
        
    }()
    
}
